package spec.tianjunxiu.unit4.task4_3;
import spec.tianjunxiu.unit4.task4_1.HireUser;
public  class HireUserDAOImp  implements IUserDAO {
    private HireUser[] hu = new HireUser[2];
    public HireUserDAOImp() {//初始化对象数组
        for (int i = 0; i < hu.length; i++) {
            hu[i] = new HireUser();
            hu[i].setUserID(i + 1);
        }
    }
//判断求租客户是否存在
    public boolean isEixist(HireUser hireUser) {
        boolean flag = false;
        for (int i = 0; i < hu.length; i++) {
            if (hu[i].getUserID() == hireUser.getUserID()) {
                flag = true;//求租客户已经存在
                break;
            }
        }
        return flag;
    }
//添加求租客户
    public void insertUser(HireUser hireUser) {
        int length = hu.length;
        //判断hireUser是否是HireUser对象
        if (hireUser instanceof HireUser) {
            //重新创建数组，使得长度增1
            HireUser[] h = hu;
            hu = new HireUser[length + 1];
            //原来的数组值迁移
            for (int i = 0; i < h.length; i++) {
                hu[i] = h[i];
            }
            hu[length] = hireUser;
        } else {
            System.out.println("求租客户信息对象错啦");
        }

    }

    @Override
    public boolean isEixist(User u) {
        return false;
    }

    @Override
    public void insertUser(User u) {

    }
}
